<?php
	namespace Home\Controller;
	/**
	 * 前台相册控制器
	 */
	class PhotosController extends BaseController {
		/**
		 * 主页展示方法
		 */
		public function photo() {
			$photo = D('Photo');
			
			// 分页开始
				// 获取相册记录总数
				$count = $photo->getCount();
				// 创建分页对象
				$page = new \Think\NewPage($count,10);
				$page->rollPage = 5;		// 每页只显示5页
				$page->lastSuffix = false;
				$page->setConfig('prev', '上一页');
				$page->setConfig('next', '下一页');
				$page->setConfig('first', '首页');
				$page->setConfig('last', '尾页');
				// 获得分页字符串
				$pageStr = $page->show();
				// limit获取数据
				$photoData = $photo->getPhotoList($page->firstRow,$page->listRows);
			// 分页结束
				$pageStr = substr($pageStr, 5);
				$pageStr = substr($pageStr,0,-6);
			
			//$photoData = $photo->getPhotoList();
			$this->assign('visitor', $this->visitor);
			$this->assign('cateNum', count($this->headerData));
			$this->assign('cateData', $this->headerData);
			$this->assign('mostHits', $this->mostHits);
			$this->assign('AllCate', $this->AllCate);
			
			
			$this->assign('pageStr', $pageStr);
			$this->assign('photoNum', count($photoData));
			$this->assign('photoData', $photoData);
			$this->display();
		}
	}
